#include "../Helix/View/OpenGL/OpenGLSupport.h"

#include "../Helix/Helix.h"
#include "../Helix/Input.h"
#include "../Helix/Timer.h"
#include "../Helix/Math/Constants.h"
#include "InputExample.h"					// Header File For Derived Application Class
#include <math.h>

using namespace helix;

void InputExample::renderScene()
{
	glMatrixMode(GL_MODELVIEW);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
	
	
	//this is where everything in the main rendering loop should go
	glLoadIdentity();			//Reset the modelview matrix to the identity matrix

	//Translate the cube using the value from mouse input
	glTranslatef(0.0,0.0,zoom);

	//Rotate the cube with the values captured by the mouse.
	glRotatef(rotX,0.0,1.0,0.0);
	glRotatef(rotY,1.0,0.0,0.0);

	openGLHelper->drawMesh(cube);

	glFlush();
}

void InputExample::update(double dSeconds)
{
	float diffX = input->getMouseX();
	float diffY = input->getMouseY();

	if(input->leftMouse())
	{
		rotX+= diffX * DEGTORAD * 20.0f;
		rotY+= diffY * DEGTORAD * 20.0f;
	}
	else if(input->rightMouse())
	{
		zoom-=diffY*0.05f;
	}

}
